package com.itheima.test;

public class Student {
    //成员变量
    private String name;
    private int age;
    private char gender;

    //空参构造
    public Student(){

    }
    //实参构造
    public Student(String name, int age, char gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }
    //获取和返回name
    public void setname(String name) {
        this.name = name;
    }

    public String getname() {
        return name;
    }

    //获取和返回年龄
    public void setage(int age) {
        if (age > 0 && age < 50) {
            this.age = age;
        } else {
            System.out.println("非法数据");
        }
    }

    public int getage() {
        return age;
    }

    //获取和返回性别
    public void setgender(char gender) {
        this.gender = gender;
    }

    public char getgender() {
        return gender;
    }

    //成员方法
    public void sleep() {
        System.out.println("睡觉");
    }
}
